// 请求首页商品显示数据
// 手机
const oDivPhone = $('.phone-content .right-box');
const oDivAi = $('.ai-content .right-box');
const oDivTv = $('.tv-content .right-box');
demonstrate({
    kw : '手机'
}).then(res => {
    const { status, msg, data } = res;
    if (status) {
        // 这里获取关键字
        let phoneHTML = '';
        for (let i = 0; i < 8; i++){
            phoneHTML += `
            <li><a href="">
                <img src="${data[i].goods_img}" alt="">
                <h3>${data[i].goods_title}</h3>
                <p class="des">${data[i].goods_des}</p>
                <p class="price">${data[i].goods_price}元起</p>
            </a></li>
        `;
        }
        oDivPhone.html(phoneHTML);
    } else {
        alert(msg);
    }
})

// 智能穿戴
demonstrate({
    kw : '智能穿戴'
}).then(res => {
    const { status, msg, data } = res;
    if (status) {
        
        let aiHTML = '';
        for (let i = 0; i < 8; i++){
            aiHTML += `
            <li><a href="">
                <img src="${data[i].goods_img}" alt="">
                <h3>${data[i].goods_title}</h3>
                <p class="des">${data[i].goods_des}</p>
                <p class="price">${data[i].goods_price}元起</p>
            </a></li>
        `;
        }
        oDivAi.html(aiHTML);
    } else {
        alert(msg);
    }
})

// 电视
demonstrate({
    kw : '电视'
}).then(res => {
    const { status, msg, data } = res;
    if (status) {
        
        let tvHTML = '';
        for (let i = 0; i < 8; i++){
            tvHTML += `
            <li><a href="">
                <img src="${data[i].goods_img}" alt="">
                <h3>${data[i].goods_title}</h3>
                <p class="des">${data[i].goods_des}</p>
                <p class="price">${data[i].goods_price}元起</p>
            </a></li>
        `;
        }
        oDivTv.html(tvHTML);
    } else {
        alert(msg);
    }
})
